<?php
/**
 * Created by PhpStorm.
 * User: Edik
 * Date: 2016/2/23
 * Time: 11:31
 */

namespace Admin\Controller;


use Admin\Model\MemberModel;
use Think\Controller;

class IndexController extends Controller
{
    /**
     * 后台用户登陆
     */
    function index(){
        if(IS_POST){
            $Member = new MemberModel();

            $m = $Member->login(I('post.username'), I('post.password'));

            if($m == 0){
                $this->error("用户不存在!");
            }elseif($m == 1){
                $this->redirect('Admin/Home/index');
            }else{
                $this->error("密码不正确!");
            }
        }



        $this->display();
    }

    function logout(){
        session(null);
        $this->redirect('index');
    }
}